<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "course_schedule".
 *
 * @property int $ID ID
 * @property int $JXKCID 教学课程ID
 * @property int|null $KSZ 开始周
 * @property int|null $JSZ 结束周
 * @property int|null $XQJ 星期几
 * @property string|null $JCSJ 节次/时间
 * @property string|null $SKDD 上课地点
 *
 * @property CourseTeacher $jXKC
 */
class CourseSchedule extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'course_schedule';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['ID', 'JXKCID'], 'required'],
            [['ID', 'JXKCID', 'KSZ', 'JSZ', 'XQJ'], 'integer'],
            [['JCSJ', 'SKDD'], 'string', 'max' => 20],
            [['ID'], 'unique'],
            [['JXKCID'], 'exist', 'skipOnError' => true, 'targetClass' => CourseTeacher::className(), 'targetAttribute' => ['JXKCID' => 'ID']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'ID' => 'ID',
            'JXKCID' => '教学课程ID',
            'KSZ' => '开始周',
            'JSZ' => '结束周',
            'XQJ' => '星期几',
            'JCSJ' => '节次/时间',
            'SKDD' => '上课地点',
        ];
    }

    /**
     * Gets query for [[JXKC]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getJXKC()
    {
        return $this->hasOne(CourseTeacher::className(), ['ID' => 'JXKCID'])->inverseOf('courseSchedules');
    }
}
